raw=input().split(" ")
[l,w]=[int(i) for i in raw]

raw=input().split(" ")
data=[int(i) for i in raw]

ret=[]

hashtable=[0]*(w+1)
mapper={}

class Node:
    def __init__(self,val):
        self.val=val
        self.next=None
offset=0
for i in range(w):
    if data[i] in mapper:
        mapper[data[i]]+=1
    else:
        mapper[data[i]]=1

offset=0
for i in mapper:
    offset=max(offset,mapper[i])
    if hashtable[mapper[i]]==0:
        hashtable[mapper[i]]=Node(mapper[i])
    else:
        t=hashtable[mapper[i]]
        if t.val>mapper[i]:
            hashtable[mapper[i]]=Node(mapper[i])
            hashtable[mapper[i]].next=t
        while t and t.val<mapper[i]:
            t=t.next
            temp=t.next
            t.next=Node(i)
            t.next.next=temp

ret.append(hashtable[offset].val)

for i in range(l-w):
    t=hashtable[mapper[data[i]]]
    if t.val==data[i]:
        hashtable[mapper[data[i]]]=t.next
    else:
        while t.next.val !=data[i]:
            t=t.next
        t.next=t.next.next
    mapper[data[i]]-=1
    t=hashtable[mapper[data[i]]]
    if t.val>mapper[data[i]]:
        hashtable[mapper[data[i]]]=Node(mapper[data[i]])
        hashtable[mapper[data[i]]].next=t
    while t and t.val<mapper[data[i]]:
        t=t.next
        temp=t.next
        t.next=Node(data[i])
        t.next.next=temp    

        
